import request from '@/utils/request';
import Qs from 'qs';
import { SelectionRecordQueryParams } from '@/api/group/investmentPromotion/types'
/**
 * 新增招商_商品
 * @param data
 */
export const productsBusiness = (data: { productsId?: string; inventory?: string }[]) => {
  return request({
    url: '/electroniccommerce/productsBusiness',
    method: 'post',
    data: data
  });
};

/**
 * 查询招商_商品列表
 * @param data
 */
export const productsBusinessList = (query: SelectionRecordQueryParams) => {
  return request({
    url: '/electroniccommerce/productsBusiness/list',
    method: 'get',
    params: query
  });
};

/**
 * 上架招商_商品
 * @param data
 */
export const putOn = (data: any) => {
  return request({
    url: '/electroniccommerce/productsBusiness/putOn',
    method: 'put',
    data: data
  });
};

/**
 * 下架招商_商品退还给供应商
 * @param data
 */
export const putOff = (data: { id?: string; inventory?: string }[]) => {
  return request({
    url: '/electroniccommerce/productsBusiness/putOff',
    method: 'put',
    data: data
  });
};

/**
 * 修改商品提报状态为破损补样邀约
 * @param id
 */
export const damageInviteId = (data: [{ id: string, productsId: string }]) => {
  return request({
    url: '/electroniccommerce/productsBusiness/damageInvite',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品提报状态为样品邀约
 * @param id
 */
export const inviteId = (id: Array<string | number>) => {
  return request({
    url: '/electroniccommerce/hmProducts/invite/' + id,
    method: 'post',
  });
};

/**
 * 修改商品提报状态为补样邀约
 * @param id
 */
export const againInviteId = (id: string) => {
  return request({
    url: '/electroniccommerce/hmProducts/againInvite/' + id,
    method: 'post',
  });
};

/**
 * 导出招商_商品列表
 * @param id
 */
export const productsBusinessExport = (data: { id: string | number; }[]) => {
  return request({
    url: '/electroniccommerce/productsBusiness/export',
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    responseType: 'blob',
    data: Qs.stringify(data)
  });
};

/**
 * 导出商品卡
 * @param id
 */
export const exportCertId = (id: string) => {
  return request({
    url: `/basic/hmProducts/exportCert/${id}`,
    method: 'get',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    responseType: 'blob',
  });
};

/**
 * 一审二审三审无合同产品部变价 审批
 * @param id
 */
export const auditAction = (data: any) => {
  return request({
    url: `/basic/hmProducts/auditAction`,
    method: 'post',
    data
  });
};

/**
 * pc二审审批
 * @param id
 */
export const auditSecond = (data: any) => {
  return request({
    url: `/basic/hmProducts/auditSecond`,
    method: 'post',
    data
  });
};

/**
 * 新-变价驳回
 * @param id
 */
export const reject = (data: any) => {
  return request({
    url: `/basic/changeAudit/reject`,
    method: 'post',
    data
  });
};

/**
 * 新-变价同意
 * @param id
 */
export const pass = (data: any) => {
  return request({
    url: `/basic/changeAudit/pass`,
    method: 'post',
    data
  });
};

/**
 * 研发组长审批
 * @param id
 */
export const hmauditGroupInvent = (data: any) => {
  return request({
    url: `/basic/hmProducts/auditGroupInvent`,
    method: 'post',
    data
  });
};

/**
 * 研发总监初审审批
 * @param id
 */
export const auditSecondInvent = (data: any) => {
  return request({
    url: `/basic/hmProducts/auditSecondInvent`,
    method: 'post',
    data
  });
};

/**
 * 研发总监复审审批
 * @param id
 */
export const auditThirdInvent = (data: any) => {
  return request({
    url: `/basic/hmProducts/auditThirdInvent`,
    method: 'post',
    data
  });
};
